package com.cherrypt.api.model.bo;

import com.cherrypt.api.model.dataobject.*;
import com.cherrypt.api.model.dto.DoubanDto;
import com.cherrypt.api.model.dto.ImdbDto;
import com.cherrypt.api.model.dto.PostDto;
import com.cherrypt.api.model.dto.SeriesDto;
import com.cherrypt.api.model.util.BeanUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @author intent
 * @date 2019/8/2 16:16
 * @about <link href='http://zzyitj.xyz/'/>
 */
public class PostBo {
    public static PostDto getPostDto(Post post, String username, String categoryName,
                                     List<SeriesDto> seriesDtoList, DoubanDto douban, ImdbDto imdb) {
        PostDto postDTO = new PostDto();
        BeanUtils.copyFieldToBean(post, postDTO);
        if (StringUtils.isNotBlank(username)) {
            postDTO.setUsername(username);
        }
        if (StringUtils.isNotBlank(categoryName)) {
            postDTO.setCategoryName(categoryName);
        }
        if (seriesDtoList.size() > 0) {
            postDTO.setSeriesList(seriesDtoList);
        }
        if (douban != null) {
            postDTO.setDouban(douban);
        }
        if (imdb != null) {
            postDTO.setImdb(imdb);
        }
        return postDTO;
    }
}
